"""
run the revised alpabeta against the dummy agent, and compare the three factor that combine 'alot':
num_con, glob_sum_dis, variance
"""
from agent import agent
from agent1 import agent as agent1
from game_runner import GameRunner
from loa_game import WHITE, BLACK, LinesOfActionState, SpinAction, MoveAction, DIRECTIONS, Direction
from game_agent import GameAgent
from alpha_beta import AlphaBetaSearch
from heu import alot, num_con, variance, glob_sum_dis


class DummyAgent(GameAgent):
    def move(self, game_state):
        for action in game_state.getSuccessors().keys():
            return action
    
    def setup(self, player, game_state, turn_time_limit, setup_time_limit):
        return

agents = {}
agents[WHITE] = agent(1)
print agents[WHITE].depth
agents[BLACK] = DummyAgent()

state = LinesOfActionState(6, 50)

states, winner = GameRunner(state, agents, 20, 20).run()
states = states[WHITE]
print 'Winner:', winner

#print states
num_con_data = map(num_con,states)
variance_data = map(variance,states)
sum_dis_data = map(glob_sum_dis,states)


"""ploting data"""

import matplotlib.pyplot as plt
import numpy as np


p1, = plt.plot(range(len(sum_dis_data)), sum_dis_data,'g')
p2, = plt.plot(range(len(variance_data)), variance_data,'b')
p3, = plt.plot(range(len(num_con_data)), num_con_data,'r')

plt.legend( (p1, p2, p3), ('sum', 'var', 'num', ) )
plt.show()
